// Decompiled on 周六 2月 22 19:31:49 CST 2025 with Zomboid Decompiler v0.1.3 using Vineflower.
package zombie.audio.parameters;

import zombie.audio.FMODGlobalParameter;
import zombie.characters.IsoGameCharacter;
import zombie.characters.IsoPlayer;
import zombie.characters.Moodles.MoodleType;

public final class ParameterMoodlePanic extends FMODGlobalParameter {
    public ParameterMoodlePanic() {
        super("MoodlePanic");
    }

    @Override
    public float calculateCurrentValue() {
        IsoGameCharacter isoGameCharacter = this.getCharacter();
        return isoGameCharacter == null ? 0.0F : (float)isoGameCharacter.getMoodles().getMoodleLevel(MoodleType.Panic) / 4.0F;
    }

    private IsoGameCharacter getCharacter() {
        IsoPlayer isoPlayer0 = null;

        for (int _int = 0; _int < IsoPlayer.numPlayers; _int++) {
            IsoPlayer isoPlayer1 = IsoPlayer.players[_int];
            if (isoPlayer1 != null
                && (isoPlayer0 == null || isoPlayer0.isDead() && isoPlayer1.isAlive() || isoPlayer0.Traits.Deaf.isSet() && !isoPlayer1.Traits.Deaf.isSet())) {
                isoPlayer0 = isoPlayer1;
            }
        }

        return isoPlayer0;
    }
}
